package com.dongdongshop.config;


import com.dongdongshop.jop.OrderJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzOrderConfig {

    @Bean
    public JobDetail jobDetail(){
        return JobBuilder.newJob(OrderJob.class)
                .withIdentity("jobName2","jobGroup")
                .storeDurably()//group 组名,name值在这个组中必须唯一
                .build();
    }
    @Bean
    public Trigger trigger() {
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/9 * * * * ?");
        return TriggerBuilder.newTrigger()
                .forJob(jobDetail())
                .withSchedule(cronScheduleBuilder)
                .build();
    }
}
